import request from "@/utils/request";
import type { GetAttrParams, AttrList, AttrItem } from "./model/attrModels";

const enum API {
  getAttrList = "/admin/product/attrInfoList",
  delAttrList = "/admin/product/deleteAttr",
  addAttrInfo = "/admin/product/saveAttrInfo",
}

/**
 * 获取属性列表展示
 * @param param0
 * @returns
 */
export const getAttrListApi = ({
  category1Id,
  category2Id,
  category3Id,
}: GetAttrParams) => {
  return request.get<any, AttrList>(
    API.getAttrList + `/${category1Id}/${category2Id}/${category3Id}`
  );
};

/**
 * 删除属性
 * @param attrId
 * @returns
 */
export const delAttrListApi = (attrId: number) => {
  return request.delete(API.delAttrList + `/${attrId}`);
};

/**
 * 添加属性
 * @param data
 * @returns
 */
export const addAttrInfoApi = (data: AttrItem) => {
  return request.post(API.addAttrInfo, data);
};
